home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
-
- Allow source code to be compiled with both ANSI and K&R compilers.
-
- Copyright 1991,1992 Lee Iverson
-
- Author:
- Lee Iverson <leei@mcrcim.mcgill.edu>,
- McGill Research Centre for Intelligent Machines (McRCIM)
-
- See <McImage/copyright.h> for complete copyright information.
-
- $Id: proto.h,v 1.3 92/02/06 15:47:05 leei Exp $
-
- Usage: By conforming to the standard declaration style suggested
- herein, one can create source which will compile properly under
- both K&R and ANSI C implementations. I hope that the
- macros don't inhibit readability too much.
-
- * Function declaration (e.g. forward or extern declarations.)
-
- extern int foo __((float a, float b));
- - or -
- extern int foo _DCL((a), float a _AND float b);
- - or -
- extern int foo _D((a), float a _AND float b);
-
- Void functions are handled specially:
-
- extern int foo __((void));
- - or -
- extern int foo _DCL_VOID();
- - or -
- extern int foo _DVOID();
-
- * Function implementation.
-
- int foo _IMPL((a), float a _AND float b)
- - or -
- int foo _I((a), float a _AND float b)
- {
- ...
- }
-
- Void functions are handled specially:
-
- extern int foo _IMPL_VOID()
- - or -
- extern int foo _IVOID()
- {
- ...
- }
-
- * Token concatenation (useful in constructive macros).
-
- CONCAT(a_,b) => a_b
- CONCAT3(a_,b,_c) => a_b_c
-
- * Stringify (only valid inside a macro expansion).
-
- STRING(foo) => "foo"
-
- * New keywords in ANSI have no effect in K&R! (e.g. const, volatile)
-
- ******************************************************************************/
-
- #ifndef _proto_h_
- #define _proto_h_
-
- # if defined(__STDC__) || defined(__STDMPL__)
-
- # ifndef __
- # define __(x) x
- # endif
- # ifndef _DCL
- # define _DCL(args, dcls) (dcls)
- # define _DCL_VOID() (void)
- # define _IMPL(args, dcls) (dcls)
- # define _IMPL_VOID() (void)
-
- # define _D(args, dcls) (dcls)
- # define _DVOID() (void)
- # define _I(args, dcls) (dcls)
- # define _IVOID() (void)
-
- # define _AND ,
- # endif
-
- # define CONCAT(x,y) x##y
- # define CONCAT3(x,y,z) x##y##z
- # define STRING(x) #x
-
- # else
-
- # ifndef __
- # define __(x) ()
- # endif
- # ifndef _DCL
- # define _DCL(args, dcls) ()
- # define _DCL_VOID() ()
- # define _IMPL(args, dcls) args dcls;
- # define _IMPL_VOID() ()
-
- # define _D(args, dcls) ()
- # define _DVOID() ()
- # define _I(args, dcls) args dcls;
- # define _IVOID() ()
-
- # define _AND ;
- # endif
-
- # define signed
- # define const
- # define volatile
-
- # define CONCAT(x,y) x/**/y
- # define CONCAT3(x,y,z) x/**/y/**/z
- # define STRING(x) "x"
-
- # endif /* __STDC__ */
-
- #endif /* _proto_h_ */
-